<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="${path}/order/admin/getOrdersInfo">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="userName" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">订单号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="ordersNo" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">订单状态</label>
                            <div class="layui-input-inline">
                                <input type="text" name="state" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <%--<script type="text/html" id="toolbarDemo">--%>
        <%--    <div class="layui-btn-container">--%>
        <%--        <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add">添加</button>--%>
        <%--        <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除</button>--%>
        <%--    </div>--%>
        <%--</script>--%>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        <div id="test"></div>
        <script type="text/html" id="currentTableBar">

        </script>

    </div>

</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>

<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;
        form.render();
        table.render({
            elem: '#currentTableId',
            url: '${path}/order/admin/getOrdersInfo',
            height: 650,
            cellMinWidth: 80,
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '订单信息表',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'id', width: 150, title: 'ID', sort: true, align: "center"},
                {field: 'ordersNo', width: 150, title: '订单号',sort: true, align: "center"},
                {field: 'total', width: 150, title: '总价',sort: true, align: "center"},
                {field: 'price', width: 150, title: '单价', align: "center"},
                {field: 'time', width: 120, title: '时间',sort: true,align: "center"},
                {field: 'state', width: 120, title: '订单状态', align: "center"},
                {field: 'userId', width: 180, title: '用户id', align: "center"},
                {field: 'movieName', width: 180, title: '电影名', align: "center"},
                {field: 'seats', width: 120, title: '座位号', align: "center",edit: 'text'},
                {field: 'userName', width: 80, title: '用户名', align: "center"},
                {title: '操作', minWidth: 120, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'line',
            done:function (){
                $("[data-field='identity']").children().each(function(){
                    if($(this).text()=='1'){
                        $(this).text("是")
                    }else if($(this).text()=='0'){
                        $(this).text("否")
                    }
                });
                $("[data-field='power']").children().each(function(){
                    if($(this).text()=='1'){
                        $(this).text("管理员")
                    }else if($(this).text()=='0'){
                        $(this).text("用户")
                    }
                });
            }
        });


        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            let result = JSON.stringify(data.field);
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');
            return false;
        });

        //监
        // 听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });


    });
</script>
</body>
</html>